<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%-- Add portlet taglibs to jsp --%>
<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<portlet:defineObjects/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src='/${requestScope.contextPath}/scripts/common.js' ></script>

<b>Demo Using Form in MVCPortlet - Data validation configuration</b>
<br/>
<form name="<portlet:namespace/>add" action="<portlet:actionURL/>" method="POST" enctype="multipart/form-data">
  <input type="hidden" name="screenId" value="Add"/>
  <input type="hidden" name="eventId"/>
  <font color="red">${requestScope.ERROR}</font>
  <br/>
  <p style="color: blue">
  ${requestScope.MESSAGE}
  </p>
  
  <%-- Dislay errors --%>
  <p style="color: red">
  <c:forEach var="error" items="${errors}">
    ${error.fieldName}: ${error.errorMessage}
    <br/>
  </c:forEach>
  </p>
  <table border="0" width="55%" cellspacing="0" cellpadding="0">
    <tr>
      <td width="120">User name(*)</td>
      <td>

        <p>
          <input type="text" name="username" size="20"
            value="${requestScope.formBean.username}">
        </p>
      </td>
    </tr>
    <tr>
      <td width="120">Birthday</td>
      <td nowrap="nowrap"><input type="text" name="birthday" size="10" value="${requestScope.formBean.birthday}">(dd/mm/yyyy;
        &lt;= tomorrow)</td>
    </tr>
    <tr>
      <td width="120">Address (max: 300 characters)</td>
      <td><textarea rows="2" name="address" cols="20" value="${requestScope.formBean.address}"></textarea>
      </td>
    </tr>
    <tr>
      <td width="120">Toefl mark</td>
      <td><input type="text" name="toeflMark" size="10" value="${requestScope.formBean.toeflMark}"> (0
        ~ 1000)</td>
    </tr>
    <tr>
      <td width="120">Picture</td>
      <td><input type="file" name="attachedFile"/></td>
    </tr>
    <tr>
      <td width="120">The attached file will be saved at folder (on server):</td>
      <td><input name="rootPath" value="${requestScope.formBean.rootPath}"></td>
    </tr>
  </table>
  <input type="button" name="save" value="Save" onclick='submitAction("<portlet:namespace/>","add","save");'/>
  &nbsp;
  &nbsp;
  <input type="button" name="list" value="List" onclick='submitAction("<portlet:namespace/>","add","list");'/>
  <br/>
</form>
  